<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>优家购房系统 - 房租信息管理</title>
		<script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
	<!-- 引入css -->
	<link href="css/bootstrap.min.css" rel="stylesheet" />
	<!-- 使用bootstrap前端框架，首先引入jquery -->
	<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
	<!-- 引入js插件 -->
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="css/main.css">
	<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css">
	<script type="text/javascript">
		$(document).ready(function(){
			var sex='${sex}';
			$("#test option").each(function(){
				if($(this).val()==sex){
					$(this).attr("selected",true);
				}
			});
		});
	</script>
	
	
</head>
<body style="background:url('image/bg2.jpg');background-size:cover;">
<div class="box">
	<h3>房租信息管理</h3>
	<div class="actions">
		<div>
			<a class="btn btn-primary" href="view/rent/add.jsp">添加房租信息</a>
		</div>
		<div>
			<form action="RentServlet2" method="post">
				<input type="hidden" name="method" value="select">
				租户姓名:<input name="name" placeholder="请输入房租名称" value="${name}">
				租户手机号:<input name="phone" placeholder="租户电话号码" value="${phone}">
				最初缴纳房租的时间:
				<input name="startDate" placeholder="缴纳金额的时间上限" value="${startDate}" class="Wdate" onClick="WdatePicker()">
				最后缴纳房租的时间:
				<input name="endDate" placeholder="缴纳金额的时间下限" value="${endDate}" class="Wdate" onClick="WdatePicker()">
				<button type="submit"><span class="glyphicon glyphicon-search" style="color:red;"></span></button>
			</form>
		</div>
	</div>

	<table class="list">
		<tr>
			<th>序号</th>
			<th>房屋id号</th>
			<th>租户id号</th>
			<th>租户姓名</th>
			<th>租户电话</th>
			<th>缴纳金额</th>
			<th>缴纳时间</th>
			<th>备注</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${list }" var="rent" varStatus="status">
		<tr>
			<td>${status.count }</td>
			<td>${rent.flat_id }</td>
			<td>${rent.tenant_id }</td>
			<td>${rent.l_name }</td>
			<td>${rent.l_tel }</td>
			<td>${rent.r_money }</td>
			<td>${rent.r_time }</td>
			<td>${rent.r_remark }</td>
			<td>
				<a title="编辑" href="RentServlet2?method=grbi&id=${rent.r_id }">
				<span class="glyphicon glyphicon-edit" style="color:blue;"></span>
				</a>
				&nbsp;&nbsp;
				<a title="删除"  onclick="confirmDelete(${rent.r_id})">
				<span class="glyphicon glyphicon-trash" style="color:red;"></span>
				</a>
			</td>
		</tr>
		</c:forEach>
	</table>
	<div>
		<c:url value="RentServlet2?method=select" var="forward">
			<c:param name="pageIndex" value="${pageIndex-1 }"></c:param>
			<c:param name="name" value="${name }"></c:param>
			<c:param name="phone" value="${phone }"></c:param>
			<c:param name="startDate" value="${startDate }"></c:param>
			<c:param name="endDate" value="${endDate }"></c:param>
		</c:url>
		<c:url value="RentServlet2?method=select" var="next">
			<c:param name="pageIndex" value="${pageIndex+1 }"></c:param>
			<c:param name="name" value="${name }"></c:param>
			<c:param name="phone" value="${phone }"></c:param>
			<c:param name="startDate" value="${startDate }"></c:param>
			<c:param name="endDate" value="${endDate }"></c:param>
		</c:url>
	</div>
	<div class="pager-info">
		<div>第 ${pageIndex }/${totalPages } 页 </div>
		<div>
			<ul class="pagination">
				<li class="paginate_button previous disabled }">
				<c:if test="${pageIndex > 1 }">
					<a href="${forward }">上一页</a>
				</c:if>
				</li>
				<li class="paginate_button active">
					<form action="RentServlet2?method=select" method="post">
					<input type="hidden" name="name" value="${name }">
					<input type="hidden" name="phone" value="${phone }">
					<input type="hidden" name="startDate" value="${startDate }" class="Wdate" onClick="WdatePicker()">
					<input type="hidden" name="endDate" value="${endDate }" class="Wdate" onClick="WdatePicker()">
					请选择跳转的页码:
					<input name="pageIndex">
					<input type="submit" value="跳转">
					</form>
				</li>
				<li class="paginate_button next disabled">
					<c:if test="${pageIndex < totalPages }">
				<a href="${next }">下一页</a>
				</c:if>
				</li>
			</ul>
		</div>
	</div>
</div>
<script src="lib/jquery/jquery.js"></script>
<script>
function confirmDelete(id){
	if (confirm("确定要删除码？")) {
		window.location="RentServlet2?method=delete&id="+id;
	}
	return false;
}
</script>
</body>
</html>